<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <!--MD5加密工具类-->
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>

</head>
<body>
<!--表达绑定提交事件
        οnsubmit= 绑定一个提交检测的函数，true，false
        将这个结果返回给表单，使用onsubmit接收
-->
<form action="#" method="post" onsubmit="return check()">
    <p>
        <span>用户名:</span>
        <input type="text" id="username" name="username">
    </p>
    <p>
        <span>密码:</span>
        <input type="password" id="pwd">
        <!--使用隐藏域传递密码更安全-->
        <input type="hidden" id="md5pwd" name="md5pwd">
    </p>

    <input type="submit">
</form>

<script>

    function check() {
        let username = document.getElementById("username");
        let pwd = document.getElementById("pwd");
        let md5pwd = document.getElementById("md5pwd");

        // 通过md5()方法加密
        md5pwd.value = md5(pwd.value);
        //可以校验判断表单内容，true就是通过提交，false就是阻止提交
        return true;
    }

</script>

</body>
</html>